﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Client2.ServiceReference1;

namespace Client2
{
    class Program
    {
        const string MY_ID = "client2";

        static void Main(string[] args)
        {
            Service1Client client = new Service1Client();

            while (true)
            {
                var evs = client.GetEvents(MY_ID);
                if (evs != null)
                {
                    foreach (var ev in evs)
                    {
                        if (ev != null)
                        {
                            var eventObj = client.GetEvent(MY_ID, ev);
                            client.OnEventRecived(MY_ID, ev);

                            string res = "";
                            var type = eventObj.GetType();
                            var properties = type.GetProperties();
                            foreach (var property in properties)
                            {
                                res += property.GetValue(eventObj, null).ToString() + "\n";
                            }
                            Console.WriteLine(res);
                        }
                    }
                }
                System.Threading.Thread.Sleep(100);
            }

            // Always close the client.
            client.Close();
        }
    }
}
